package com.lingyun.mqttserver.controller;

import com.lingyun.mqttserver.dao.pojo.DeviceInfo;
import com.lingyun.mqttserver.service.ManageDataService;
import com.lingyun.mqttserver.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Objects;

// 设备管理
@RestController
@RequestMapping("device-info")
public class DeviceInfoController {

    @Autowired
    private ManageDataService manageDataService;

    @GetMapping("deviceList")
    public Result DeviceList(Integer projectId, Integer deviceTypeId, String deviceName, Integer pageNum, Integer pageSize){
        return manageDataService.DeviceList(projectId, deviceTypeId, deviceName, pageNum, pageSize);
    }

    @PostMapping("deviceAdd")
    public Result DeviceAdd(@RequestBody DeviceInfo deviceInfo){
        return manageDataService.DeviceAdd(deviceInfo);
    }

    @PostMapping("deviceUpdate")
    public Result deviceUpdate(@RequestBody DeviceInfo deviceInfo){
        return manageDataService.deviceUpdate(deviceInfo);
    }

    @DeleteMapping("deviceDelete")
    public Result DeviceDelete(@RequestParam Integer id){
        return manageDataService.DeviceDelete(id);
    }

    // 设备详细信息
    @GetMapping("deviceDetail")
    public Result deviceDetail(@RequestParam Integer id){
        return manageDataService.deviceDetail(id);
    }

    // 所有设备状态
    @GetMapping("deviceStatus")
    public Result deviceStatus(){
        return manageDataService.deviceStatus();
    }
}
